#include<stdio.h>
#define N 100003
long long f(long long n,long long m)
{
	long long temp=1;
	while(n!=1)
	{
		if(n%2)
			temp=(m*temp)%N;
		m=(m*m)%N;
		n/=2;
	}
	m=(temp*m)%N;
	return m;
}
int main()
{
	long long n,m,sum1=0,sum2=0,temp;
	scanf("%lld%lld",&m,&n);
	m%=N;n%=N;
	if(n!=1)
	{
		sum1=f(n,m);
		sum2=(m*f(n-1,m-1))%N;
		printf("%lld\n",(sum1+N-sum2)%N);
	}
	else
		printf("0\n");
	return 0;
}
